#!/bin/sh
# - test

## NetPIPE is a protocol independent performance tool that encapsulates
## the best of ttcp and netperf and visually represents the network
## performance under a variety of conditions.

. $LKP_SRC/lib/debug.sh

cd $BENCHMARK_ROOT/netpipe || die "no $BENCHMARK_ROOT/netpipe"

[ -n "$direct_server_ips" ] && server=$direct_server_ips
[ -z "$server" ] && server=127.0.0.1
server=${server%% *}

fixup_mpi()
{
	# fix 'make: mpicc: No such file or directory'
	# fix '/bin/sh: 1: mpirun: not found'
	if [ -e "/usr/lib64/openmpi/bin/mpicc" -a -e "/usr/lib64/openmpi/bin/mpirun" ];then
                ln -sf /usr/lib64/openmpi/bin/mpicc /usr/bin/mpicc
                ln -sf /usr/lib64/openmpi/bin/mpirun /usr/bin/mpirun
        else
                ln -sf /usr/bin/mpicc.openmpi /usr/bin/mpicc
                ln -sf /usr/bin/mpirun.openmpi /usr/bin/mpirun
        fi
}

fixup_mpi

log_cmd make CFLAGS="-fcommon" $test || die "failed to compile $test"

case $test in
mpi )
	echo "$server slots=1" > mpihost
	log_cmd mpirun -np 1 --hostfile mpihost --allow-run-as-root NPmpi --repeats 1000 2>&1
	;;
esac
